package com.fg.cloud.manager.service.product.impl;

import java.math.BigDecimal;
import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fg.cloud.manager.entry.BaseEntity;
import com.fg.cloud.manager.entry.product.ProductSkuEntity;
import com.fg.cloud.manager.mapper.BaseMapper;
import com.fg.cloud.manager.mapper.product.ProductSkuMapper;
import com.fg.cloud.manager.service.BaseServiceImpl;
import com.fg.cloud.manager.service.product.ProductSkuService;

/**
 * @author liushengchao
 * @Description: 商品SKU接口实现类 
 * @date 2017年6月26日上午11:21:31
 *
 */
@Service
public class ProductSkuServiceImpl extends BaseServiceImpl implements ProductSkuService{
	@Autowired
	private ProductSkuMapper skuMapper;
	
	@Override
	protected <T extends BaseEntity> BaseMapper getBaseMapper() {
		return skuMapper;
	}
	
	/**
	 * 修改商品SKU价格
	 */
	@Override
	@Transactional
	public int updatePrice(BigDecimal productPrice, Long id) {
		return skuMapper.updatePrice(productPrice, id);
	}
	
	/**
	 * 通过商品ID查询商品SKU信息
	 */
	@Override
	public List<ProductSkuEntity> selectByProId(@Param("productId")Long productId) {
		return skuMapper.selectByProId(productId);
	}

	/**
	 * 商品SKU上下架
	 */
	@Override
	@Transactional
	public int skuUpAndDown(Long id, int ground) {
		return skuMapper.productUpAndDown(id, ground);
	}

	/**
	 * 逻辑删除商品SKU
	 */
	@Override
	@Transactional
	public int deleteSku(Long id) {
		return skuMapper.deleteSku(id);
	}

	@Override
	public int batchDelete(String[] ids) {
		return skuMapper.batchDelete(ids);
	}

}
